package com.news.servlet;

import com.news.common.BaseServlet;
import com.news.common.CommonResult;
import com.news.common.ServletResp;
import com.news.entity.Category;
import com.news.service.CmsCategoryService;
import com.news.service.impl.CmsCategoryServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author:weiming
 * @Date:2021/4/19
 */
@WebServlet("/category/*")
public class CategoryServlet extends BaseServlet {

    private CmsCategoryService cmsCategoryService = new CmsCategoryServiceImpl();

    public void getCategoryCanUse(HttpServletRequest request, HttpServletResponse response){

        List<Category> allCategoryCanUse = cmsCategoryService.getAllCategoryCanUse();
        if (allCategoryCanUse != null) {
            ServletResp.resp(response, CommonResult.success(allCategoryCanUse));
        }else {
            ServletResp.resp(response, CommonResult.failed());
        }

    }

}
